﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary
{
    /// <summary>
    /// This class provides a rotation matrix for two dimensional vectors.
    /// </summary>
    [Serializable]
    public class RotationMatrix2D
    {
        /// <summary>
        /// The rotation angle for the transformation.
        /// </summary>
        private double rotationAngle;

        /// <summary>
        /// Initializes a new instance of the <see cref="RotationMatrix2D"/> class.
        /// </summary>
        /// <param name="rotationAngle">The rotation angle in radians.</param>
        public RotationMatrix2D(double rotationAngle)
        {
            this.rotationAngle = rotationAngle;
        }

        /// <summary>
        /// Gets or sets the rotation angle.
        /// </summary>
        /// <value>The rotation angle.</value>
        public double RotationAngle
        {
            get { return rotationAngle; }
            set { rotationAngle = value; }
        }

        /// <summary>
        /// Gets the rotation matrix for a plane space R².
        /// </summary>
        /// <returns>The rotation matrix for a plane space R².</returns>
        public Matrix GetRotationMatrix()
        {
            double[,] matrixData = new double[2,2];

            matrixData[0, 0] = Math.Cos(this.rotationAngle);
            matrixData[0, 1] = -Math.Sin(this.rotationAngle);

            matrixData[1, 0] = Math.Sin(this.rotationAngle);
            matrixData[1, 1] = Math.Cos(this.rotationAngle);

            return new Matrix(matrixData);
        }
    }
}